#include "ProcessPool.hpp"
#include <ctime>

int main()
{
    std::cout << "程序启动" << std::endl;
    srand((unsigned int)time(nullptr));
    ProcessPool processpool;
    // 生成n个测试任务
    int n = 10;
    for(int i = 0; i < 10; i++)
    {
        processpool.RegisterTask(([i](){std::cout << "进程" << getpid() << "正在执行任务" << i << std::endl;}));
    }
    processpool.Start();
    while(n--)
    {
        int code = rand() % 10;
        processpool.LaunchTask(code);
        sleep(2);
    }
    processpool.Stop();
    return 0;
}